<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>购物车</title>
    <style>
        *{  
            margin:0;
            padding:0;
            list-style-type: none;    
        }
        .box{
            width:1000px;
            margin:50px auto;
        }
        ul li{
            text-align: center; 
            box-sizing:border-box;  
            border: 1px solid #000; 
        }
        .title{
            width:100%;
            height:50px;
            background:#f66;  
        }
        .title .t_nav{
            float: left;
            width: 24.9%;
            height:50px;
            line-height: 50px;
            border-right:1px solid #000;
        }
        .title span:nth-child(4){
            border-right:0 solid #000;
        }
        .header{
            width:100%;
            height:100px;
            border:1px solid #000;
        }
        .header .t_header{
            float: left;
            width:24.9%;
            height:100px;
            line-height:100px;
            border-right:1px solid #000;
        }
        .header .img1{
            background:url("imgs/shop1.jpg") 50%/100px 90px no-repeat;
        }
        .header .img2{
            background:url("imgs/shop2.jpg") 50%/100px 90px no-repeat;
        }
        .header .img3{
            background:url("imgs/shop3.jpg") 50%/100px 90px no-repeat;
        }
        .header .img4{
            background:url("imgs/shop4.jpg") 50%/100px 90px no-repeat;
        }
        .header p{
            width: 130px;
            height:30px;
            margin:35px auto;
            border:1px solid #ddd;
        }
        .header p>span{
            float: left;
            line-height: 30px;
        }
        .add,.minue{
            width:30px;
            height:30px;
            background-color: #bbb;
        }
        .count{
            width:70px;
        }
        .footer{
            width:100%;
            height:50px;
            background-color: #f66;
            margin:20px auto;
        }
        .footer>p{
            float: right;
            width:130px;
            height:50px;
            margin-right:30px;
            text-align: center;
            line-height: 50px;
        }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li class="title">
                <span class="t_nav">商品</span>
                <span class="t_nav">单价</span>
                <span class="t_nav">数量</span>
                <span class="t_nav">小计</span>
            </li>
            <li class="header">
                <div class="t_header img1"></div>
                <div class="t_header">8</div>
                <div class="t_header">
                    <p>
                        <span class="minue">-</span>
                        <span class="count">0</span>
                        <span class="add">+</span>
                    </p>
                </div>
                <div class="t_header">0</div>
            </li>
            <li class="header">
                <div class="t_header img2"></div>
                <div class="t_header">10</div>
                <div class="t_header">
                    <p>
                        <span class="minue">-</span>
                        <span class="count">0</span>
                        <span class="add">+</span>
                    </p>
                </div>
                <div class="t_header">0</div>
            </li>
            <li class="header">
                <div class="t_header img3"></div>
                <div class="t_header">12.5</div>
                <div class="t_header">
                    <p>
                        <span class="minue">-</span>
                        <span class="count">0</span>
                        <span class="add">+</span>
                </div>
                <div class="t_header">0</div>
            </li>
            <li class="header">
                <div class="t_header img4"></div>
                <div class="t_header">13</div>
                <div class="t_header">
                    <p>
                        <span class="minue">-</span>
                        <span class="count">0</span>
                        <span class="add">+</span>
                    </p>
                </div>
                <div class="t_header">0</div>
            </li>
        </ul>
        <div class="footer">
            <p>合计费用<span>0</span></p>
            <p> 已选中商品<span>0</span>个</p>
        </div>
    </div>
    <script>
        //1.获取数量+
        var oMin = document.getElementsByClassName("minue"),
        oAdd = document.getElementsByClassName("add"),
        oCount = document.getElementsByClassName("count"),
        arrCount=[];//所有商品个数
       
        length=oAdd.length;
        
        for(var i =0; i<length;i++){
            oAdd[i].index = i;
            oMin[i].index = i;
            arrCount[i] =0;//循环 给单个数量初始化
            oAdd[i].onclick = function(){
                var index = this.index;//取出当前值
               oCount[index]++;
               changNum(index);
            }
          
        }
    </script>
</body>
</html>